package thrift.hello;

import com.to8to.kitt.esb.DefaultServerDeamon;
import com.to8to.kitt.esb.NodeChangeEvent;
import com.to8to.kitt.utils.LogUtils;

public class HelloServerESB extends DefaultServerDeamon{

	@Override
	public void onCommonConfigChange(NodeChangeEvent e) {
		
		if(e != null && e.isChange())
		{
			if(e.path.contains("logback.xml"))
			{
				String logbackConfig = new String(e.ndata);
				String real = logbackConfig.replace("${java.service}", service).replace("${java.instance}", instance);
				System.out.println("加载logback.xml:\n" + real);
				LogUtils.resetConfigByData(real);
			}
		}
	}
	
	public static void main(String[] args)  {
		
		HelloIface iface = new HelloIface();
		
		HelloServerESB server = new HelloServerESB();
		
		server.addCommonConfigPath("crm/common/logback.xml");

		server.start(iface, HelloService.class, args[0]);
	}
	
}
